<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!doctype html>
<html>
  <head>
    <script>
      performance.mark("code/didStartRenderer")
    </script>
    <meta charset="utf-8" />

    <!-- Mobile tweaks -->
    <meta name="mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-title" content="Code" />
    <link
      rel="apple-touch-icon"
      href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/haystack-192.png"
    />

    <!-- Disable pinch zooming -->
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"
    />

    <!-- Workbench Configuration -->
    <meta
      id="vscode-workbench-web-configuration"
      data-settings="{{WORKBENCH_WEB_CONFIGURATION}}"
    />

    <!-- Workbench Auth Session -->
    <meta
      id="vscode-workbench-auth-session"
      data-settings="{{WORKBENCH_AUTH_SESSION}}"
    />

    <!-- Builtin Extensions (running out of sources) -->
    <meta
      id="vscode-workbench-builtin-extensions"
      data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}"
    />

    <!-- Workbench Icon/Manifest/CSS -->
    <link
      rel="icon"
      href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/favicon.ico"
      type="image/x-icon"
    />
    <link
      rel="manifest"
      href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json"
      crossorigin="use-credentials"
    />
  </head>

  <body aria-label=""></body>

  <!-- Startup (do not modify order of script tags!) -->
  <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
  <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
  <script>
    const baseUrl = new URL(
      "{{WORKBENCH_WEB_BASE_URL}}",
      window.location.origin,
    ).toString()

    Object.keys(self.webPackagePaths).map(function (key, index) {
      if (key === "zustand/middleware" || key === "zustand/vanilla") {
        self.webPackagePaths[key] =
          `${baseUrl}/remote/web/node_modules/zustand/${self.webPackagePaths[key]}`
      } else {
        self.webPackagePaths[key] =
          `${baseUrl}/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`
      }
    })
    require.config({
      baseUrl: `${baseUrl}/out`,
      recordStats: true,
      trustedTypesPolicy: window.trustedTypes?.createPolicy("amdLoader", {
        createScriptURL(value) {
          if (value.startsWith(window.location.origin)) {
            return value
          } else if (value === "pixi.js") {
            // TODO: This hack should not be necessary. Look into why Pixi specifically does not work.
            const endPosition = window.location.pathname.indexOf("/out/")
            const outLength = "/out/".length
            const truncatedPath = window.location.pathname.substring(
              0,
              endPosition + outLength,
            )
            return `${
              window.location.origin
            }${truncatedPath}${baseNodeModulesPath}/pixi.js/dist/pixi${
              isDev ? "" : ".min"
            }.js`
          }
          throw new Error(`Invalid script url: ${value}`)
        },
      }),
      paths: self.webPackagePaths,
    })
  </script>
  <script>
    performance.mark("code/willLoadWorkbenchMain")
  </script>
  <script>
    require(["vs/code/browser/workbench/workbench"], function () {})
  </script>
</html>
